feat: implement rebuild indexes functionality for documents#979
Conversation
- Implemented a new API endpoint to rebuild specified types of indexes for a document. - Added corresponding request and response models for the rebuild indexes functionality. - Updated the frontend to include a modal for selecting index types to rebuild. - Enhanced the document management UI with a rebuild index option in the dropdown menu. - Added localization support for rebuild index messages in both English and Chinese.
- Added a new API endpoint to rebuild specified types of indexes for a document. - Introduced request and response models for the rebuild indexes feature. - Updated the document service to handle index rebuilding logic. - Enhanced the main view with a new endpoint for triggering index rebuilds. - Included logging for index rebuild operations and success responses.
🚨 BugBot couldn't runSomething went wrong. Try again by commenting "bugbot run", or contact support (requestId: serverGenReqId_46150768-d3f6-4e9d-9f82-d06d2cdbc205). |
|
bugbot run |
There was a problem hiding this comment.
Bug: API Contract Violation: Incorrect Response Code
The rebuild_indexes endpoint's OpenAPI specification defines a 204 No Content response, but the document_service.py implementation returns a 200 OK with a JSON body {"code": "200", "message": "..."}. This mismatch between the API contract and implementation can cause client issues.
aperag/api/paths/collections.yaml#L321-L324
ApeRAG/aperag/api/paths/collections.yaml
Lines 321 to 324 in e380ab0
aperag/service/document_service.py#L457-L461
ApeRAG/aperag/service/document_service.py
Lines 457 to 461 in e380ab0
Bug: Verification Queries Execute Outside Transaction
The rebuild_document_indexes method's transaction function (_rebuild_document_indexes_atomically) performs verification queries (self.db_ops.query_document, self.db_ops.query_collection) using a global db_ops instance instead of the transaction's session parameter. This causes these queries to execute outside the transaction, breaking isolation and potentially leading to race conditions or inconsistent reads. These verification queries should either be moved outside the transaction or rewritten to use the provided session.
aperag/service/document_service.py#L440-L451
ApeRAG/aperag/service/document_service.py
Lines 440 to 451 in e380ab0
Was this report helpful? Give feedback by reacting with 👍 or 👎
No description provided.